Don't ignore the passed-in len parameter. (#430049, Yevgen Muntyan)
authorMatthias Clasen <mclasen@redhat.com>
Mon, 9 Jul 2007 20:24:26 +0000 (20:24 +0000)
committerMatthias Clasen <matthiasc@src.gnome.org>
Mon, 9 Jul 2007 20:24:26 +0000 (20:24 +0000)
2007-07-09  Matthias Clasen  <mclasen@redhat.com>

        * gtk/gtkselection.c (normalize_to_crlf): Don't ignore
        the passed-in len parameter.  (#430049, Yevgen Muntyan)

svn path=/trunk/; revision=18423

ChangeLog
gtk/gtkselection.c

index e875da455689f88a86ee2e72a9e53d444f0d3493..b257b2938b3ec7657e808ed08e7cf4046bfbaa9b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2007-07-09  Matthias Clasen  <mclasen@redhat.com>
+
+       * gtk/gtkselection.c (normalize_to_crlf): Don't ignore
+       the passed-in len parameter.  (#430049, Yevgen Muntyan)
+
 2007-07-09  Matthias Clasen  <mclasen@redhat.com>
 
        * gtk/gtkframe.c (gtk_frame_size_allocate): Improve the
index b76090be200499f7ef0b1e96d4157ee2b7d7d56a..16eb1c802d9ae289805651b083607669b9923fef 100644 (file)
@@ -1197,8 +1197,9 @@ normalize_to_crlf (const gchar *str,
 {
   GString *result = g_string_sized_new (len);
   const gchar *p = str;
+  const gchar *end = str + len;
 
-  while (1)
+  while (p < end)
     {
       if (*p == '\n')
        g_string_append_c (result, '\r');
@@ -1207,13 +1208,12 @@ normalize_to_crlf (const gchar *str,
        {
          g_string_append_c (result, *p);
          p++;
-         if (*p != '\n')
+         if (p == end || *p != '\n')
            g_string_append_c (result, '\n');
+         if (p == end)
+           break;
        }
 
-      if (*p == '\0')
-       break;
-
       g_string_append_c (result, *p);
       p++;
     }